home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 8
/
Mac Magazin and MacEasy Magazine CD - Issue 08.iso
/
Sharewarebibliothek
/
Updater⁄Infos
/
Mausefalle 1.1.2 -> 1.1.3
/
Terminal 2.2 Skript
< prev
Wrap
Text File
|
1993-08-29
|
4KB
|
187 lines
/*
Terminal 2.0 script
Login and do "Maustausch" with Maus AC
*/
int flg;
int err,outfile_err,infile_err;
int timeout = 1800; /* 30 seconds */
int redial_t = 1800; /* Redial-Time = 30s */
char line[80];
char init_s[] = "ATZ\r"; /* modem init-string */
char prefix[] = "ATDP"; /* dial-string */
char number[] = "500482"; /* number for Maus AC */
char user_name[] = "Frank Sample\r"; /* user name */
char password[] = "geheim\r"; /* password */
char infile [32] = "infile.Txt";
char outfile [32] = "outfile.txt";
hangup()
{
pause(120);
check("+++","OK",300); /* Go into command mode */
type("ATH0\r"); /* Hang up */
beep();
}
/* ----- Send command and wait for reply ------------------------------- */
check(char *command, char *reply, int timeout)
{
type(command);
return prompt(reply, timeout);
}
/* ----- Wait for prompt and send command ------------------------------ */
answer(char *hint, char *command)
{
int result;
if (result = prompt(hint, timeout))
return result; /* Timeout or cancel */
pause(30); /* Don't type immediatly */
type(command);
return 0;
}
/* ----- Strip leading control characters (like LFs) ------------------- */
Strip(char *line)
{
while (*line && (*line < 0x20 || *line > 0x7E))
++line;
return line;
}
/* ----- Initialyse modem and terminal ---------------------------------- */
init()
{
err = 0;
terminal (0,0,0,1);
setup(
8, /* 8=57600 baud */ /* refer to your modem-manual! */
1, /* 8 data */
0, /* no parity */
0, /* 1 stop */
-1, /* port: no change */
-1, /* DTR: no change */
4); /* 4=Handshake: CTS/DTR */
if (check(init_s, "OK", 600)) { /* Modem init */
err = 1;
display ("No modem connected?\r"); /* no modem */
return 0;
}
pause(30);
return 1;
}
/* ----- if no infile.txt take default infile --------------------------*/
set_infile()
{
char fname;
int ftype,fdsize,frsize,fcdate,fmdate;
err = catalog (0,infile,&ftype,&fdsize,&frsize,&fcdate,&fmdate);
if (err) {
infile = def_infile;
return;
}
if (fdsize <= 2)
infile = def_infile;
}
delete_infile()
{
if (!infile_err) { /* if upload ok */
if (strcmp(infile,def_infile)) {
capture(1,infile); /* deletes contents of infile */
display("#\r");
capture(0,infile);
}
}
}
/* ----- Connect with mailbox -------------------------------------------*/
connect()
{
char *s;
int repeat = 1;
while (repeat) {
display ("Dialing for mailbox -- ");
type ("%s%s\r",prefix , number); /* dial number */
pause(120);
if (!(err = prompt("CONNECT",timeout+900))) { /* repeat if busy */
display ("connect\r");
repeat = 0;
}
else
display ("busy\r");
if (err == 2) {
display ("Dial canceled! (err=%i)\r",err);
return 0;
}
}
return 1;
}
/* ----- log into mailbox -------------------------------------------------*/
login()
{
int ok = 1;
while (ok) {
if (answer("(J/N)","MausTausch"))
break;
type("%s", user_name);
type("%s", password);
ok = 0;
}
if (!ok) {
display ("Login successful!\r");
}
}
logoff()
{
hangup();
}
maustausch()
{
answer("Protokoll:","Z");
prompt("Protokoll startet",timeout);
display ("Sending InFile!\r");
infile_err = upload (infile,0,1); /* no MacBinary, use Z-Modem */
prompt("Protokoll startet",timeout);
display ("Receiving OutFile!\r");
outfile_err = download (outfile,1,1); /* detect MacBinary, use Z-Modem */
}
/* ----- Main program -------------------------------------------------- */
main()
{
save (0);
set_infile();
if (init())
if (connect()) {
login();
maustausch();
logoff();
delete_infile();
}
save(1);
return 257; /* exit programm */
}